package com.caac.core.web.action.log;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.caac.core.web.action.BaseAction;
import com.caac.core.web.form.BaseForm;
import com.caac.core.web.form.SysLogDeleteForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright caac 2005</p>
 * <p>Company: caac</p>
 * @author <a href="mailto:project@caac.com.cn">Project Group</a>
 * @version 1.0
 */

public class DeleteSysLogAction extends BaseAction {
    protected ActionForward doExecute(ActionMapping mapping,
                                      BaseForm form,
                                      HttpServletRequest request,
                                      HttpServletResponse response) throws java.
            lang.Exception {
        SysLogDeleteForm myForm = (SysLogDeleteForm) form;
        JdbcTemplate manager = (JdbcTemplate)this.getBean("jdbcTemplate");
        if (myForm.getOperateTime() != null) {
            manager.execute("delete from t_sys_log where opt_time<to_date('" +
                            myForm.getOperateTimeString() + "','YYYY-MM-DD')");
            ActionMessages messages = new ActionMessages();
            messages.add("deleteSysLog",
                         new ActionMessage("messages.deleteSysLog"));
            saveMessages(request, messages);
        }
        return forward(mapping);
    }
}
